package com.elegantmall.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.elegantmall.pojo.UserContactPojo;
import com.elegantmall.pojo.UserPojo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserDao extends BaseMapper<UserPojo> {
    @Select("SELECT * FROM user")
    List<UserPojo> getAllUsers();

    @Update("UPDATE user_contact SET address = #{address}, telephone = #{telephone} WHERE username = #{username}")
    int updateUserContact(@Param("username") String username, @Param("address") String address, @Param("telephone") String telephone);
    @Select("SELECT username,address, telephone FROM user_contact WHERE username = #{username}")
    UserContactPojo getUserContactByUsername(@Param("username") String username);
    @Insert("INSERT INTO user_contact (username, address, telephone) VALUES (#{username}, #{address}, #{telephone})")
    void insertUserContact(UserContactPojo userContactPojo);


}

